package it.polimi.meteocal_pappalardo_sacchi.bean;

import it.polimi.meteocal_pappalardo_sacchi.entity.BadWeatherNotificationWithSuggestion;
import it.polimi.meteocal_pappalardo_sacchi.entity.Event;
import it.polimi.meteocal_pappalardo_sacchi.entity.Notification;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.List;

/**
 *
 *
 */
@Named
@RequestScoped
public class NotificationSnippetBean implements Serializable {

    @Inject
    private NotificationManager notificationManager;
    @Inject
    private UserBean userBean;


    List<Notification> unreadNotificationByUser;
    private int unreadNotificationNumberByUser;

    @PostConstruct
    private void init() {
        unreadNotificationByUser = notificationManager.findNotificationByUser(userBean.getUser(), false);
        unreadNotificationNumberByUser = getUnreadNotificationByUser().size();
    }

    public List<Notification> getUnreadNotificationByUser() {
        return unreadNotificationByUser;
    }

    public int getUnreadNotificationNumberByUser() {
        return unreadNotificationNumberByUser;
    }

    public void setUnreadNotificationNumberByUser(int unreadNotificationNumberByUser) {
        this.unreadNotificationNumberByUser = unreadNotificationNumberByUser;
    }
}
